package com.eternal.base.data.ble;

import com.clj.fastble.data.BleDevice;
import com.clj.fastble.scan.BleScanRuleConfig;
import com.eternal.base.concat.DeviceMinModel;
import com.eternal.base.concat.DeviceModel;
import com.eternal.base.concat.DeviceSetting;
import com.eternal.base.concat.DeviceTFP;
import com.eternal.base.database.entity.History;
import com.eternal.base.database.entity.Log;
import com.eternal.base.database.entity.Notification;

import java.util.List;

import io.reactivex.Completable;
import io.reactivex.Observable;
import io.reactivex.Single;

public interface IBleControl {
    /**
     * 关闭蓝牙扫描
     */
    void closeScan();

    void clean();

    boolean isConnect(String mac);

    BleStatue getConnect(String mac);

    List<BleDevice> disableBle();

    Single<Boolean> syncCTime(BleStatue statue);

    /**
     * 扫描蓝牙设备
     *
     * @return
     */
    Single<List<BleDevice>> scan(BleScanRuleConfig config);

    Observable<List<BleDevice>> scanCycle(BleScanRuleConfig config);

    Single<BleStatue> connect(BleDevice device, BleServer.DisconnectListener listener);

    Observable<DeviceModel> getBroadcast(BleStatue statue);

    Single<DeviceTFP> getTFP(String mac, byte command);

    Single<Boolean> setSetting(String mac, DeviceSetting setting);

    Single<Boolean> setBSetting(String mac, DeviceSetting setting);

    Single<Boolean> setCSetting(String mac, DeviceSetting setting);

    Single<Boolean> setESetting(String mac, byte port, DeviceSetting setting);

    Single<DeviceSetting> getSetting(BleStatue statue);

    Single<DeviceSetting> getBSetting(BleStatue statue);

    Single<DeviceSetting> getCSetting(BleStatue statue);

    Single<DeviceSetting> getESetting(BleStatue statue, byte port);

    Single<DeviceMinModel> getModel(BleStatue statue, final byte port);

    Single<DeviceMinModel> getCModel(final BleStatue statue);

    Single<Boolean> setModel(BleStatue statue, byte port, DeviceModel model);

    Single<Boolean> setCModel(BleStatue statue, DeviceModel model);

    Single<Boolean> setModel(BleStatue statue, byte port, byte model);

    Single<DeviceModel> initMode(BleStatue statue, byte port);

    void disConnect(BleStatue statue);

    void disConnectC();

    Single<Boolean> setNotification(BleStatue statue, Notification notification, boolean isExit, boolean isOpen);

    Single<List<Notification>> getNotifications(BleStatue statue, byte port);

    Single<List<Notification>> getNotifications(BleStatue statue);

    Observable<Log> getLog(BleStatue statue, long start, int id);

    Observable<Log> getELog(final BleStatue statue, final byte port, long start, final int id);

    Observable<Log> getCLog(final BleStatue statue, final long start);

    Observable<History> getCHistory(final BleStatue statue, final long start);

    Observable<History> getHistory(BleStatue statue, long start);

    Observable<History> getEHistory(BleStatue statue, long start);

    Completable syncConnectedTime();

    Single<Boolean> setChoosePort(BleStatue statue, byte port);

    Single<Boolean> getTempUnit(BleStatue statue);
}
